class Bg extends imageClass{
    constructor(game){
        super(game, "bg1")
        this.game = game
        this.setup()
    }

    setup(){
        this.frameCount = config.action_speed
        this.frameIndex = 0
        this.frames = []
        this.x = 0
        this.y = 0
        this.inversion = false

        for (var i = 1; i <= kofFrame.bg.count; i ++){
            var name = "bg" + `${i}`
            var t = this.game.textureByName(name)
            this.frames.push(t)
        }

    }

    update(){
        self = this
        self.frameCount -- 
        if (self.frameCount == 0){
            self.frameCount = config.action_speed
            self.frameIndex = (self.frameIndex + 1) % kofFrame.bg.count
        }
        self.texture = self.frame()
    }

    frame(){
        return this.frames[this.frameIndex]
    }
}